package org.example.repository.condition;

import org.example.repository.Condition;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

public class ConjectionCondition extends Condition {

    private final String type;
    private final List<Condition> children = new ArrayList<>();

    public ConjectionCondition(String type) {
        this.type = type;
    }

    public ConjectionCondition(String type, Collection<Condition> conditions) {
        this.type = type;
        children.addAll(conditions);
    }

    public ConjectionCondition(String type, Condition... conditions) {
        this.type = type;
        children.addAll(Arrays.asList(conditions));
    }

    public String getType() {
        return type;
    }

    public List<Condition> getChildren() {
        return children;
    }

    public void add(Condition condition) {
        children.add(condition);
    }

    @Override
    public String toString() {
        return "ConjectionCondition{" +
                "type='" + type + '\'' +
                ", children=" + children +
                '}';
    }
}
